{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>dteday</th>\n",
       "      <th>season</th>\n",
       "      <th>yr</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>casual</th>\n",
       "      <th>registered</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "      <td>331</td>\n",
       "      <td>654</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2011-01-02</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "      <td>131</td>\n",
       "      <td>670</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2011-01-03</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "      <td>120</td>\n",
       "      <td>1229</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2011-01-04</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "      <td>108</td>\n",
       "      <td>1454</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2011-01-05</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "      <td>82</td>\n",
       "      <td>1518</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant      dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
       "0        1  2011-01-01       1   0     1        0        6           0   \n",
       "1        2  2011-01-02       1   0     1        0        0           0   \n",
       "2        3  2011-01-03       1   0     1        0        1           1   \n",
       "3        4  2011-01-04       1   0     1        0        2           1   \n",
       "4        5  2011-01-05       1   0     1        0        3           1   \n",
       "\n",
       "   weathersit      temp     atemp       hum  windspeed  casual  registered  \\\n",
       "0           2  0.344167  0.363625  0.805833   0.160446     331         654   \n",
       "1           2  0.363478  0.353739  0.696087   0.248539     131         670   \n",
       "2           1  0.196364  0.189405  0.437273   0.248309     120        1229   \n",
       "3           1  0.200000  0.212122  0.590435   0.160296     108        1454   \n",
       "4           1  0.226957  0.229270  0.436957   0.186900      82        1518   \n",
       "\n",
       "    cnt  \n",
       "0   985  \n",
       "1   801  \n",
       "2  1349  \n",
       "3  1562  \n",
       "4  1600  "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import sys\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "%matplotlib inline\n",
    "\n",
    "df = pd.read_csv(\"day.csv\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "\n",
    "\n",
    "df['date'] = pd.to_datetime(df['dteday'])\n",
    "df['dayofyear'] = df['date'].dt.dayofyear\n",
    "\n",
    "y = df['cnt']\n",
    "X = df.drop(['casual', 'registered', 'cnt', 'dteday', 'date', 'season','mnth','weathersit','weekday'], axis = 1)\n",
    "\n",
    "fest_names = X.columns\n",
    "\n",
    "ss_X = StandardScaler()\n",
    "ss_y = StandardScaler()\n",
    "\n",
    "X = ss_X.fit_transform(X)\n",
    "y = ss_y.fit_transform(y.values.reshape(-1, 1))\n",
    "\n",
    "fe_data = pd.DataFrame(data = X, columns = fest_names, index = df.index)\n",
    "\n",
    "categorical_features = ['season','mnth','weathersit','weekday']\n",
    "for col in categorical_features:\n",
    "    df[col] = df[col].astype('object')\n",
    "    x_cat = pd.get_dummies(df[col], prefix=col)\n",
    "    fe_data = pd.concat([fe_data, x_cat], axis=1, ignore_index=False)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(584, 35)"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(fe_data, y, random_state=33, test_size=0.2)\n",
    "X_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "r2 lr score of test:  (0.4224857480073679+0j)\n",
      "r2 lr score of train:  (0.3846615359040585+0j)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "from sklearn.metrics import mean_squared_error\n",
    "import cmath\n",
    "fest_names = fe_data.columns\n",
    "\n",
    "lr = LinearRegression()\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "# fs = pd.DataFrame({\"columns\":list(fest_names), \"coef\":list((lr.coef_.T))})\n",
    "# fs.sort_values(by=['coef'], ascending=False)\n",
    "\n",
    "print('r2 lr score of test: ', cmath.sqrt(mean_squared_error(y_test, y_test_pred_lr)))\n",
    "print('r2 lr score of train: ', cmath.sqrt(mean_squared_error(y_train, y_train_pred_lr)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "r2 lr score of test ridge:  (0.41705879012693825+0j)\n",
      "r2 lr score of train ridge:  (0.3845237467130185+0j)\n"
     ]
    }
   ],
   "source": [
    "from sklearn.linear_model import RidgeCV\n",
    "\n",
    "alphas = [0.01, 0.1, 1, 10, 100]\n",
    "\n",
    "ridge = RidgeCV(alphas = alphas, store_cv_values = True)\n",
    "\n",
    "ridge.fit(X_train, y_train)\n",
    "\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "print('r2 lr score of test ridge: ', cmath.sqrt(mean_squared_error(y_test, y_test_pred_ridge)))\n",
    "print('r2 lr score of train ridge: ', cmath.sqrt(mean_squared_error(y_train, y_train_pred_ridge)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "r2 score of test lasso: 0.8318731973039811\n",
      "r2 score of train lasso: 0.8510666077900987\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\develop\\python3\\lib\\site-packages\\sklearn\\linear_model\\_coordinate_descent.py:1088: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n",
      "d:\\develop\\python3\\lib\\site-packages\\sklearn\\linear_model\\_coordinate_descent.py:474: ConvergenceWarning: Objective did not converge. You might want to increase the number of iterations. Duality gap: 0.30939154427717597, tolerance: 0.05794960753215885\n",
      "  model = cd_fast.enet_coordinate_descent(\n"
     ]
    }
   ],
   "source": [
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "lasso = LassoCV()\n",
    "\n",
    "lasso.fit(X_train, y_train)\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "print('r2 score of test lasso:', r2_score(y_test, y_test_pred_lasso))\n",
    "print('r2 score of train lasso:', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>columes</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>coef_lasso</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>yr</td>\n",
       "      <td>[34471872476577.977]</td>\n",
       "      <td>[0.34626024584841986]</td>\n",
       "      <td>0.492741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>dayofyear</td>\n",
       "      <td>[19929664284070.605]</td>\n",
       "      <td>[-0.19534196839422124]</td>\n",
       "      <td>-0.157857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>mnth_9</td>\n",
       "      <td>[0.6592761382654435]</td>\n",
       "      <td>[0.44307672437123413]</td>\n",
       "      <td>0.492155</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>mnth_10</td>\n",
       "      <td>[0.4822352921590003]</td>\n",
       "      <td>[0.2002839969258139]</td>\n",
       "      <td>0.283611</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>weathersit_1</td>\n",
       "      <td>[0.464162835424506]</td>\n",
       "      <td>[0.44847937915359726]</td>\n",
       "      <td>0.251292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>season_4</td>\n",
       "      <td>[0.4325493298691416]</td>\n",
       "      <td>[0.416738351502323]</td>\n",
       "      <td>0.368231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>temp</td>\n",
       "      <td>[0.3121690635358304]</td>\n",
       "      <td>[0.29774265442949677]</td>\n",
       "      <td>0.329164</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>mnth_12</td>\n",
       "      <td>[0.3100463931876957]</td>\n",
       "      <td>[-0.12325423787488399]</td>\n",
       "      <td>-0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>mnth_8</td>\n",
       "      <td>[0.283622320692837]</td>\n",
       "      <td>[0.12447223955051517]</td>\n",
       "      <td>0.143371</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>mnth_11</td>\n",
       "      <td>[0.2166260058486497]</td>\n",
       "      <td>[-0.13919303244376469]</td>\n",
       "      <td>-0.029326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>weathersit_2</td>\n",
       "      <td>[0.2074312164049966]</td>\n",
       "      <td>[0.19812917845658173]</td>\n",
       "      <td>-0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>mnth_6</td>\n",
       "      <td>[0.10763691295346227]</td>\n",
       "      <td>[0.1186661219444165]</td>\n",
       "      <td>0.123775</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>atemp</td>\n",
       "      <td>[0.09998020857502345]</td>\n",
       "      <td>[0.13389153485106497]</td>\n",
       "      <td>0.109042</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>weekday_6</td>\n",
       "      <td>[0.09343929417609728]</td>\n",
       "      <td>[0.10217166910257358]</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>weekday_5</td>\n",
       "      <td>[0.051233455119781834]</td>\n",
       "      <td>[0.0476152075358125]</td>\n",
       "      <td>0.014128</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>season_2</td>\n",
       "      <td>[0.04645801949358922]</td>\n",
       "      <td>[0.05019513506483908]</td>\n",
       "      <td>0.007838</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>weekday_3</td>\n",
       "      <td>[0.04636510951329232]</td>\n",
       "      <td>[0.0389116257270099]</td>\n",
       "      <td>0.006594</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>workingday</td>\n",
       "      <td>[0.03910616755429981]</td>\n",
       "      <td>[0.03885657318535962]</td>\n",
       "      <td>0.005646</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>weekday_4</td>\n",
       "      <td>[0.03317998191800274]</td>\n",
       "      <td>[0.03132721876014466]</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>mnth_5</td>\n",
       "      <td>[0.007888499159601785]</td>\n",
       "      <td>[0.11515456901460897]</td>\n",
       "      <td>0.116479</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>weekday_2</td>\n",
       "      <td>[-0.004369569956273006]</td>\n",
       "      <td>[-0.010355460619245638]</td>\n",
       "      <td>-0.034620</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>holiday</td>\n",
       "      <td>[-0.033805103737185156]</td>\n",
       "      <td>[-0.027252223798789554]</td>\n",
       "      <td>-0.039706</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>season_3</td>\n",
       "      <td>[-0.07402801162535842]</td>\n",
       "      <td>[-0.054999884328628235]</td>\n",
       "      <td>-0.079635</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>mnth_7</td>\n",
       "      <td>[-0.08715822393069052]</td>\n",
       "      <td>[-0.16816212462203683]</td>\n",
       "      <td>-0.152837</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>weekday_1</td>\n",
       "      <td>[-0.09355305587231905]</td>\n",
       "      <td>[-0.09398580688538916]</td>\n",
       "      <td>-0.118870</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>windspeed</td>\n",
       "      <td>[-0.09651638866391082]</td>\n",
       "      <td>[-0.10028499961238146]</td>\n",
       "      <td>-0.099417</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>hum</td>\n",
       "      <td>[-0.10222589009154166]</td>\n",
       "      <td>[-0.1055756315209413]</td>\n",
       "      <td>-0.103603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>weekday_0</td>\n",
       "      <td>[-0.11911621191513799]</td>\n",
       "      <td>[-0.11568445362090862]</td>\n",
       "      <td>-0.212326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>mnth_4</td>\n",
       "      <td>[-0.24855833515996767]</td>\n",
       "      <td>[-0.051555913526334596]</td>\n",
       "      <td>-0.046288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>mnth_3</td>\n",
       "      <td>[-0.28310869317673076]</td>\n",
       "      <td>[0.013877454867353034]</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>season_1</td>\n",
       "      <td>[-0.3971487330068671]</td>\n",
       "      <td>[-0.4119336022385365]</td>\n",
       "      <td>-0.461621</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>mnth_2</td>\n",
       "      <td>[-0.6335692117090921]</td>\n",
       "      <td>[-0.23642521976102904]</td>\n",
       "      <td>-0.249086</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>weathersit_3</td>\n",
       "      <td>[-0.6809697205105157]</td>\n",
       "      <td>[-0.646608557610177]</td>\n",
       "      <td>-0.867922</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>mnth_1</td>\n",
       "      <td>[-0.778141403111499]</td>\n",
       "      <td>[-0.29694057844589095]</td>\n",
       "      <td>-0.323250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>instant</td>\n",
       "      <td>[-39859216679847.17]</td>\n",
       "      <td>[0.20178869174755043]</td>\n",
       "      <td>0.032279</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         columes                  coef_lr               coef_ridge  coef_lasso\n",
       "1             yr     [34471872476577.977]    [0.34626024584841986]    0.492741\n",
       "8      dayofyear     [19929664284070.605]   [-0.19534196839422124]   -0.157857\n",
       "21        mnth_9     [0.6592761382654435]    [0.44307672437123413]    0.492155\n",
       "22       mnth_10     [0.4822352921590003]     [0.2002839969258139]    0.283611\n",
       "25  weathersit_1      [0.464162835424506]    [0.44847937915359726]    0.251292\n",
       "12      season_4     [0.4325493298691416]      [0.416738351502323]    0.368231\n",
       "4           temp     [0.3121690635358304]    [0.29774265442949677]    0.329164\n",
       "24       mnth_12     [0.3100463931876957]   [-0.12325423787488399]   -0.000000\n",
       "20        mnth_8      [0.283622320692837]    [0.12447223955051517]    0.143371\n",
       "23       mnth_11     [0.2166260058486497]   [-0.13919303244376469]   -0.029326\n",
       "26  weathersit_2     [0.2074312164049966]    [0.19812917845658173]   -0.000000\n",
       "18        mnth_6    [0.10763691295346227]     [0.1186661219444165]    0.123775\n",
       "5          atemp    [0.09998020857502345]    [0.13389153485106497]    0.109042\n",
       "34     weekday_6    [0.09343929417609728]    [0.10217166910257358]    0.000000\n",
       "33     weekday_5   [0.051233455119781834]     [0.0476152075358125]    0.014128\n",
       "10      season_2    [0.04645801949358922]    [0.05019513506483908]    0.007838\n",
       "31     weekday_3    [0.04636510951329232]     [0.0389116257270099]    0.006594\n",
       "3     workingday    [0.03910616755429981]    [0.03885657318535962]    0.005646\n",
       "32     weekday_4    [0.03317998191800274]    [0.03132721876014466]    0.000000\n",
       "17        mnth_5   [0.007888499159601785]    [0.11515456901460897]    0.116479\n",
       "30     weekday_2  [-0.004369569956273006]  [-0.010355460619245638]   -0.034620\n",
       "2        holiday  [-0.033805103737185156]  [-0.027252223798789554]   -0.039706\n",
       "11      season_3   [-0.07402801162535842]  [-0.054999884328628235]   -0.079635\n",
       "19        mnth_7   [-0.08715822393069052]   [-0.16816212462203683]   -0.152837\n",
       "29     weekday_1   [-0.09355305587231905]   [-0.09398580688538916]   -0.118870\n",
       "7      windspeed   [-0.09651638866391082]   [-0.10028499961238146]   -0.099417\n",
       "6            hum   [-0.10222589009154166]    [-0.1055756315209413]   -0.103603\n",
       "28     weekday_0   [-0.11911621191513799]   [-0.11568445362090862]   -0.212326\n",
       "16        mnth_4   [-0.24855833515996767]  [-0.051555913526334596]   -0.046288\n",
       "15        mnth_3   [-0.28310869317673076]   [0.013877454867353034]    0.000000\n",
       "9       season_1    [-0.3971487330068671]    [-0.4119336022385365]   -0.461621\n",
       "14        mnth_2    [-0.6335692117090921]   [-0.23642521976102904]   -0.249086\n",
       "27  weathersit_3    [-0.6809697205105157]     [-0.646608557610177]   -0.867922\n",
       "13        mnth_1     [-0.778141403111499]   [-0.29694057844589095]   -0.323250\n",
       "0        instant     [-39859216679847.17]    [0.20178869174755043]    0.032279"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fs = pd.DataFrame({\"columes\":list(fest_names), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\": list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'], ascending=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
